package pattern21;

/**
 * 具体的中介者类
 *
 * @author wdl
 */
public class ConcreteMediator implements IMediator {
    /**
     * 需要了解所有的具体的同事对象
     */
    private ConcreteColleague1 colleague1;
    private ConcreteColleague2 colleague2;

    public void setColleague1(ConcreteColleague1 colleague1) {
        this.colleague1 = colleague1;
    }

    public void setColleague2(ConcreteColleague2 colleague2) {
        this.colleague2 = colleague2;
    }

    /**
     * 重写发送信息方法，根据对象作出选择判断，通知对象
     * @param message 发送的消息
     * @param colleague 同事对象
     */
    @Override
    public void send(String message, BaseColleague colleague) {
        if (colleague == colleague1) {
            colleague2.notifyX(message);
        } else {
            colleague1.notifyX(message);
        }
    }
}
